Resolves #37695 - Use clsx instead of classnames#37708
Conversation
cd2abf7 to
7fd3546
Compare
anomiex
left a comment
There was a problem hiding this comment.
Looks reasonable to me. A few suggestions for simplifying the dedupe replacement inline.
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
anomiex
left a comment
There was a problem hiding this comment.
LGTM. Not hitting "Approve" just yet to give Agora a chance to review.
|
Just a quick drive-by comment, I was the one who originally started this transition and was personally responsible for the Gutenberg PR. I managed to replace the dedupe usages without much complex logic or the new dependency you're using here. The code affected seems very similar, probably copy-pasted. I suggest you take a look at what I did there in case it helps you simplify this PR and achieve better consistency. Note that I don't remember the exact approach I took, but I might have decided to simply not dedupe at all in some cases, since it doesn't really affect any functionality and the trade-off of doing the computation is probably not worth it in the first place. Just a suggestion :) thanks for applying this transition here <3 |
You may want to double-check that. |
|
Ah, yep I replaced that behavior with a very very simple alternative. If you dig in my PR you'll find my approach. With that sentence in my comment I meant cases where the resulting class name is something like "class class". |
|
Glancing at your PR, the following seem likely to be broken to me
Also, in https://github.com/WordPress/gutenberg/blob/200f7c7a210c35eb9c004da9a3e4f1062f471d57/packages/block-library/src/embed/util.js#L191-L193 you might mangle things if a class in |
The one
I can't speak to the origin of the code, but in this case it was an independent refactor; looking now at that other PR it seems the goal is slightly different, but luckily it isn't too complex! |
renatoagds
left a comment
There was a problem hiding this comment.
Just got an eyes on VideoPress and AI stuffs. LGTM
|
Internal announcement: pdWQjU-Mt-p2 |
Resolves #37695 - Use clsx instead of classnames
Proposed changes:
clsxis faster and smaller thanclassnames. Also, it is now used in Calypso (Automattic/wp-calypso#91408), in Gutenberg (WordPress/gutenberg#61138), and in@wordpresspackages.For consistency, this PR matches those changes:
classnames: 6b5518dclassnameswas replaced withclsx: b45ef16classnames/dedupedoes not have an equivalent (a dedupe version? lukeed/clsx#13), so its one use was refactored using@wordpress/token-list: a060f54Caveats:
jetpack-mu-wpcomhas its own implementation ofclassNames; I've left that intact for now. If desired, we can take a look in a separate PR.@automattic/social-previewsis a dependency, and the latest published version (2.0.1-beta.13) still has aclassnamesdependency. This was removed in the aforementioned Calypso PR, but as of yet has not been published.Internal reference: p4TIVU-aYc-p2
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
Check the code for any typos or mistakes. Pay particularly close attention to the dedupe refactor.